package utils;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import services.SystemParamService;

import com.aton.db.Config;
/**
 * 线程池
 * @author wangshaoming
 *
 */
public class ThreadPool extends ThreadPoolExecutor {
	
	private static int minSize=Integer.parseInt(SystemParamService.getValueByCacheId(BizConstants.PARAM_MAP.get("THREAD_POOL_MINSIZE")));
	private static int maxSize=Integer.parseInt(SystemParamService.getValueByCacheId(BizConstants.PARAM_MAP.get("THREAD_POOL_MAXSIZE")));
	private static int keepAlive=Integer.parseInt(SystemParamService.getValueByCacheId(BizConstants.PARAM_MAP.get("THREAD_POOL_KEEPALIVE")));
	
	private ThreadPool(int corePoolSize,int maximumPoolSize,long keepAliveTime,TimeUnit unit,
			BlockingQueue<Runnable> workQueue){
		super(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,
				new ThreadPoolExecutor.CallerRunsPolicy());
	}
	private static BlockingQueue<Runnable> queue=new LinkedBlockingQueue<Runnable>();
	private static ThreadPool threadPool=new ThreadPool(minSize,maxSize,keepAlive,TimeUnit.MILLISECONDS,queue);
	public static ThreadPool getInstance(){
		return threadPool;
	}
	@Override
	public void execute(Runnable command){
		super.execute(command);
	}
	public static void remove(Long ThreadId){
		
	}
}
